package org.example;

import org.example.Proxy.*;
import org.example.config.RpcConfig;
import org.example.constant.RpcConstant;
import org.example.pojo.User;
import org.example.Proxy.ServiceProxyFactory;
import org.example.service.UserService;
import org.example.utils.ConfigUtils;

/**
 * Hello world!
 *
 */
public class EasyConsumerApp
{
    public static void main( String[] args )
    {
        RpcConfig rpcConfig = ConfigUtils.loadConfig(RpcConfig.class, RpcConstant.DEFAULT_PREFIX);
//        System.out.println(rpcConfig);
//        UserService userService = ServiceProxyFactoryWithTcpAndRegistry.getProxy(UserService.class);
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
//        UserService userService2 = ServiceProxyFactory.getProxy(UserService.class);
//        System.out.println("userservice2:"+userService2);
//        System.out.println("userservice:"+userService);
        User user = new User();
        user.setName("JZ");

        User newUser = userService.getUser(user);
        if (newUser != null){
            System.out.println(newUser.getName());
        }else{
            System.out.println( "user === null" );
        }

    }
}
